package net.es.weathermap.metric;

import java.util.HashMap;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Random;

public class RandomUtilizationMP extends UtilizationMP implements MetricProvider {

    public List<Timestep>
        getValues(String metric, List<String> identifiers,
                  Map<String, Object> options) throws Exception {

        if (!metric.equals("utilization")) {
            throw new Exception("Invalid metric name");
        }
        Random r = new Random();
        ArrayList<Timestep> results = new ArrayList<Timestep>(); 
        HashMap<String, HashMap<String, Double>> ifceEntries =
            new HashMap<String, HashMap<String, Double>>();
        for (String id : identifiers) {
            HashMap<String, Double> result = new HashMap<String, Double>();
            result.put("capacity", r.nextDouble() * 20000.0D);
            result.put("utilization_in", r.nextDouble());
            result.put("mbps_in", r.nextDouble() * 20000.0D);
            result.put("utilization_out", r.nextDouble());
            result.put("mbps_out", r.nextDouble() * 20000.0D);
            ifceEntries.put(id, result);
        }
        Timestep timestep = new Timestep();
        timestep.setTimestep(ifceEntries);
        results.add(timestep);
        return results;
    }
}
